{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from datasets.audio import *\n",
    "import os\n",
    "from hparams import hparams\n",
    "\n",
    "n_sample = 0 #Change n_steps here\n",
    "mel_folder = 'logs-Tacotron/mel-spectrograms' #Or change file path\n",
    "mel_file = 'mel-prediction-step-{}.npy'.format(n_sample) #Or file name (for other generated mels)\n",
    "out_dir = 'wav_out'\n",
    "\n",
    "os.makedirs(out_dir, exist_ok=True)\n",
    "\n",
    "mel_file = os.path.join(mel_folder, mel_file)\n",
    "mel_spectro = np.load(mel_file)\n",
    "mel_spectro.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "wav = inv_mel_spectrogram(mel_spectro.T, hparams) \n",
    "#save the wav under test_<folder>_<file>\n",
    "save_wav(wav, os.path.join(out_dir, 'test_{}.wav'.format(mel_file.replace('/', '_').replace('\\\\', '_'))),\n",
    "        sr=hparams.sample_rate)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
